home *** CD-ROM | disk | FTP | other *** search
/ The 640 MEG Shareware Studio 2 / The 640 Meg Shareware Studio CD-ROM Volume II (Data Express)(1993).ISO / clang / ndp.zip / TEST_NDP.ASM < prev    next >
Assembly Source File  |  1987-07-31  |  4KB  |  97 lines

  1. page    60,132
  2. title   TEST_NDP.COM   Math Coprocessor Check
  3.  
  4. ; TEST_NDP -   Check for Math Coprocessor -
  5. ;                  Report Presence and Type....
  6. ;
  7. ;       FREELY adopted from Ted Forgeron's
  8. ;              article and code in PC Tech
  9. ;              Journal, Aug 87 p 43  /Psi!
  10. ;
  11. code    segment     public
  12.  
  13. assume  cs:code,ds:code       ; Set it up as
  14.         org    100h           ;     a .COM file.
  15.                               ; Don't forget to EXEBIN !!
  16. start:  jmp    begin
  17.  
  18. control dw     0
  19. checkin db     10
  20.         db     'Checking for a Math Coprocessor....',10,10,13
  21.         db     'I see $'
  22. gotnone db     'NO CHIP $'
  23. gota_87 db     'an 8087 $'
  24. gota287 db     'an 80287 $'
  25. gota387 db     'an 80387 $'
  26. goodbye db     'in here !!',10,10,'$'
  27.  
  28. begin:  mov    DX,offset checkin        ; say hello
  29.         call   tellem
  30.  
  31. ; Check for an NDP.  Don't forget to assemble with the /R option
  32. ; set in MASM or you'll bomb cuz of the coprocessor instructions.
  33.  
  34. do_we:  mov    DX,offset gotnone        ; load Ur message
  35.         fninit                          ; try to initialize NDP
  36.         mov    byte ptr control+1,0     ; clear memory byte
  37.         fnstcw control                  ; put control word in mem
  38.         mov    AH,byte ptr control+1    ; iff AH is 03h, you got
  39.         cmp    AH,03h                   ;     an NDP on board !!
  40.         je     chk_87                   ; found somethin', keep goin'
  41.         call   tellem
  42.         call   saybye
  43.  
  44. ; 'got an 8087 ??
  45.  
  46. chk_87: mov    DX,offset gota_87        ; load next message
  47.         and    control,NOT 0080h        ; turn ON interrupts (IEM=0)
  48.         fldcw  control                  ; load control word
  49.         fdisi                           ; turn OFF interrupts (IEM=1)
  50.         fstcw  control                  ; store control word
  51.         test   control,0080h            ; iff IEM=1, 8087
  52.         jz     chk287                   ; 'guess not!  March on....
  53.         call   tellem                   ; tell 'em and bail out
  54.         call   saybye
  55.  
  56. ; if not.... would you believe an 80287 maybe ??
  57.  
  58. chk287: mov    DX,offset gota287        ; load up Ur '287 message
  59.         finit                           ; set default infinity mode
  60.         fld1                            ; make infinity
  61.         fldz                            ;     by dividing
  62.         fdiv                            ;         1 by zero !!
  63.         fld    st                       ; now make a
  64.         fchs                            ;     negative infinity
  65.         fcompp                          ; compare Ur two infinities
  66.         fstsw  control                  ; iff, for 8087 or 80287
  67.         fwait                           ; 'til status word is put away
  68.         mov    AX,control               ; getchur control word
  69.         sahf                            ; putchur AH into flags
  70.         jnz    got387                   ; NO GOOD.... march on !!
  71.         call   tellem                   ; gotta be a 80287 cuz we al-
  72.         call   saybye                   ;   ready tested for an 8087
  73.  
  74. ; We KNOW that there is an NDP on board otherwise we would have bailed
  75. ; out after 'do_we'.  It isn't an 8087 or an 80287 or we wouldn't have
  76. ; gotten this far.  It's gotta be an 80387 !!
  77.  
  78. got387: mov    DX,offset gota387        ; it isn't an 8087 or an 80287
  79.         call   tellem                   ;  but we do know it is an NDP
  80.         call   saybye
  81.  
  82. tellem  proc
  83.         mov    AH,09h                   ; spread the word
  84.         int    21h
  85.         ret
  86. tellem  endp
  87.  
  88. saybye  proc
  89.         mov    DX,offset goodbye
  90.         call   tellem
  91.         mov    AX,4c00h                 ; bail out !!
  92.         int    21h
  93. saybye  endp
  94.  
  95. code    ends
  96.         end    start
  97.